package com.lagou.edu.service.impl;

import com.github.houbb.email.bs.EmailBs;
import com.lagou.edu.service.EmailService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {

    @Value("${email.address}")
    private String emailAddress;

    @Value("${email.password}")
    private String emailPassword;

    @Override
    public boolean sendEmail(String email, String code) {
        Boolean result = true;
        try {
            EmailBs.auth(emailAddress, emailPassword)
                    .content(code)
                    .sendTo(email);
        } catch (Exception e) {
            result =false;
            e.printStackTrace();
        }
        return result;
    }
}
